home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $RCSfile: Vector.c,v $
- ** Description: Simple demonstration of the vector class
- ** Copyright: (C) Copyright 1994 Paul Weterings
- ** All Rights Reserved.
- **
- ** $Author: Paul $
- ** $Revision: 1.1 $
- ** $Date: 1994/09/10 11:23:13 $
- **/
-
- #include <libraries/bgui.h>
- #include <libraries/bgui_macros.h>
- #include <libraries/gadtools.h>
- #include <clib/alib_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/bgui_protos.h>
- #include <clib/intuition_protos.h>
-
- #include <stdio.h>
- #include <stdlib.h>
-
- /*
- ** Library base pointer.
- ** NOTE: The intuition.library is opened by SAS or DICE's
- ** auto-init code.
- **/
- struct Library *BGUIBase;
-
- /*
- ** Object ID's. Please note that the ID's are shared
- ** between the menus and the gadget objects.
- **/
- #define ID_QUIT 1
- #define CLOCK_WIDTH 21
-
- /*
- ** Simple menu strip.
- **/
- struct NewMenu SimpleMenu[] = {
- NM_TITLE, "Project", NULL, 0, 0, NULL,
- NM_ITEM, "Quit", "Q", 0, 0, ( APTR )ID_QUIT,
- NM_END, NULL, NULL, 0, 0, NULL
- }
- ;
-
- int main( int argc, char *argv[] )
- {
- struct Window *window;
- Object *WO_Window, *GO_Quit, *GO_Vec;
- ULONG signal = 0, rc, tmp = 0;
- BOOL running = TRUE;
-
- /*
- ** The vector structure, filled with the data to draw the clock
- **
- ** TIP: If you are going to design your own vector imagery, make sure
- ** to keep the x-y coordinate values as small as possible: i.e. design the
- ** vector image as small as possible.
- */
- struct VectorItem clockvec[] =
- {
- 16, 16, VIF_SCALE,
- 0, 0, VIF_SHINEPEN,
- SHADOWPEN, 0, VIF_AOLDRIPEN, /* set the outline to shadowcolor */
- 0, 0, VIF_AREASTART, /* draw the inner cicle, and fill */
- 8, 2, VIF_MOVE,
- 12, 4, VIF_DRAW,
- 14, 8, VIF_DRAW,
- 12, 12, VIF_DRAW,
- 8, 14, VIF_DRAW,
- 4, 12, VIF_DRAW,
- 2, 8, VIF_DRAW,
- 4, 4, VIF_DRAW,
- 8, 2, VIF_DRAW,
- 0, 0, VIF_AREAEND,
- 0, 0, VIF_ENDOPEN,
-
- 0, 0, VIF_SHADOWPEN,
- 8, 4, VIF_MOVE, /* draw the pips */
- 8, 4, VIF_MOVE,
- 12, 8, VIF_MOVE,
- 12, 8, VIF_DRAW,
- 8, 12, VIF_MOVE,
- 8, 12, VIF_DRAW,
- 4, 8, VIF_MOVE,
- 4, 8, VIF_DRAW,
- 8, 4, VIF_MOVE,
- 8, 4, VIF_DRAW,
-
- 11, 5, VIF_MOVE, /* draw the arrows */
- 8, 8, VIF_DRAW,
- 10, 10, VIF_DRAW,
-
- 0 , 0, VIF_LASTITEM
- };
-
- /*
- ** Open the library.
- **/
- if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
- /*
- ** Create the window object.
- **/
- WO_Window = WindowObject,
- WINDOW_Title, "Vectorclass Demo",
- WINDOW_MenuStrip, SimpleMenu,
- WINDOW_SizeGadget, TRUE,
- WINDOW_MasterGroup,
- HGroupObject,
- StartMember,
- GO_Vec = ButtonObject,
- VIT_VectorArray, clockvec,
- ButtonFrame,
- EndObject, FixWidth(CLOCK_WIDTH), EndMember,
- VarSpace( 50 ),
- StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
- EndObject,
- EndObject;
-
- /*
- ** Object created OK?
- **/
- if ( WO_Window ) {
- /*
- ** Assign a key to the button.
- **/
- tmp += GadgetKey( WO_Window, GO_Quit, "q" );
- /*
- ** OK?
- **/
- if ( tmp == 1 ) {
- /*
- ** try to open the window.
- **/
- if ( window = WindowOpen( WO_Window )) {
- /*
- ** Obtain it's wait mask.
- **/
- GetAttr( WINDOW_SigMask, WO_Window, &signal );
- /*
- ** Event loop...
- **/
- do {
- Wait( signal );
- /*
- ** Handle events.
- **/
- while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
- /*
- ** Evaluate return code.
- **/
- switch ( rc ) {
-
- case WMHI_CLOSEWINDOW:
- case ID_QUIT: /* there's no break here */
- running = FALSE; /* so false is set */
- break;
- }
- }
- }
- while ( running );
- }
- else
- puts ( "Could not open the window" );
- }
- else
- puts( "Could not assign gadget keys" );
- /*
- ** Disposing of the window object will
- ** also close the window if it is
- ** already opened and it will dispose of
- ** all objects attached to it.
- **/
- DisposeObject( WO_Window );
- }
- else
- puts( "Could not create the window object" );
- CloseLibrary( BGUIBase );
- }
- else
- puts( "Unable to open the bgui.library" );
-
- return( 0 );
- }
-
- #ifdef _DCC
- int wbmain( struct WBStartup *wbs )
- {
- return( main( 0, NULL ));
- }
- #endif
-
- /*
- * $Log: Vector.c,v $
- * Revision 1.1 1994/09/10 11:23:13 Paul
- * Initial revision
- *
- */
-